package be.kdg.netpresent;

import javax.swing.ImageIcon;
import java.io.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.Vector;

public class Slide extends UnicastRemoteObject implements SlideInt {

	// Default serial ID.
	private static final long serialVersionUID = 1L;
	
	// Variable to hold the slide image information.
	private ImageIcon imgInstance;
	
	// Variable to hold the textual information added to the slide
	// to additionally provide information to the image.
	private String sImgText;
	
	// Variable holding all QnA's that rise with the presentation of this slide.
	private Vector<QnA> sQnA;

	// *******************************************
	// TODO Check is these may be erased?! Commenting seems not to generate errors
	// so it seems these are not used?
	// *******************************************
	//public static final int QUE = 0;
	//public static final int ANS = 0;

	
	// Contructor of the class. Image and text are set by the creator,
	// QnA's will be added in the process of presenting.
	public Slide(ImageIcon sImage, String sNewImgText)
			throws java.rmi.RemoteException, IOException {
		this.imgInstance = sImage;
		this.sImgText = sNewImgText;
		this.sQnA = new Vector<QnA>();
	}

	// Method used to set the image content of the current slide.
	public void setImg(ImageIcon image) throws java.rmi.RemoteException,
			IOException {
		this.imgInstance = image;

	}

	// Method used to set the text content of the current slide.
	public void setText(String sNewImgText) throws java.rmi.RemoteException {
		this.sImgText = sNewImgText;
	}
	
	// Method used to add a question the the slide.
	public void addQuestion(String question) throws java.rmi.RemoteException {		
		sQnA.add(new QnA(question));
	}
	
	// Method to answer the above added question.
	public void addAnswer(int iQueNr, String answer) throws java.rmi.RemoteException {
		sQnA.get(iQueNr).addAnswer(answer);
	}

	// Method to get the image content returned so it can be displayed.
	public ImageIcon getImage() throws java.rmi.RemoteException {
		return this.imgInstance;
	}

	// Method to get the text content returned so it can be displayed.
	public String getImgText() throws java.rmi.RemoteException {
		return this.sImgText;
	}

	// Method to get the QnA content returned so it can be displayed.
	public Vector<String> getQnA() throws java.rmi.RemoteException {
		Vector<String> tmp = new Vector<String>();
		for(int i=0; i<sQnA.size(); i++) {
			tmp.add(sQnA.get(i).getQnA());
		}
		return tmp;
	}
}
